package com.pospi.pai.yunpos.util;

import com.lany.sp.SPHelper;
import com.pospi.pai.yunpos.login.Constant;

/**
 * Created by acer on 2018/9/11.
 */

public class DzcUtil {
    //FWWWWWWEEEEEC   13位
    //FWWWWWWNNNNNC
    //FFWWWWWEEEEEC
    //FFWWWWWNNNNNC
    //FWWWWWWEEEEENNNNNC   18位
    //FFWWWWWEEEEENNNNNC

    public static String[] getRule(String code) {
        int len = 0;
        String ss = SPHelper.getInstance().getString(Constant.POS_DZC);
        String rule[] = new String[4];
        switch (ss) {
            case "FWWWWWWEEEEEC":
                rule[0] = "je";
                rule[1] = code.substring(0, 1);
                rule[2] = code.substring(1, 7);
                rule[3] = code.substring(7, 12);
                break;
            case "FWWWWWWNNNNNC":
                rule[0] = "num";
                rule[1] = code.substring(0, 1);
                rule[2] = code.substring(1, 7);
                rule[3] = code.substring(7, 12);
                break;
            case "FFWWWWWEEEEEC":
                rule[0] = "je";
                rule[1] = code.substring(0, 2);
                rule[2] = code.substring(2, 7);
                rule[3] = code.substring(7, 12);
                break;
            case "FFWWWWWNNNNNC":
                rule[0] = "num";
                rule[1] = code.substring(0, 2);
                rule[2] = code.substring(2, 7);
                rule[3] = code.substring(7, 12);
                break;
        }

        return rule;
    }

    public static boolean isPlu(String code) {
        String flag = SPHelper.getInstance().getString(Constant.POS_DZC_FLAG);
        if (code.length() == 13 ) {
            if (code.substring(0, 2).equals(flag) || code.substring(0,1).equals(flag)) {
                return true;
            }
        }

        return false;
    }



}
